import request from '@/util/request'
import type { DishesSearchForm, Dishes } from './types'
import type { Page } from '@/api/common/types'

const api: string = '/dishes-service/dishes'

/* 获取菜品列表,查询接口 */
export const getDishesList = (pageNum: number, pageSize: number, form: DishesSearchForm): Promise<Page<Dishes>> => {
    return request<Page<Dishes>, Page<Dishes>>({
        url: api + '/list',
        method: 'get',
        params: {
            pageNum,
            pageSize,
            ...form
        }
    })
}

/* 新增菜品 */
export const addDishes = (form: Dishes) => {
    return request<any, any, Dishes>({
        url: api,
        method: "post",
        data: form
    })
}

/* 编辑菜品 */
export const updateDishes = (form: Dishes) => {
    return request<any, any, Dishes>({
        url: api + `/${form.id}`,
        method: "put",
        data: form
    })
}

/* 删除菜品 */
export const deleteDishes = (id: number) => {
    return request<any, any, number>({
        url: api + `/${id}`,
        method: 'delete'
    })
}













